/*
 * Copyright (c) 2025 Industrial Software Feature Database
 */
package com.comac.ins.isfd.constant.enums;

import com.comac.ins.common.core.utils.StringUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 算法三级级分类枚举
 *
 * @author hxloongs
 * @date 2024-7-11
 */
@AllArgsConstructor
@Getter
public enum IsfdAnalysisMaterialTypeEnum {
    METAL("metal", "金属"),
    HYBRID_STRUCTURE("hybrid_structure", "混合结构"),
    COMPOSITE("composite", "复合材料");
    private final String value;
    private final String desc;

    public static String getDescByValue(String value) {
        IsfdAnalysisMaterialTypeEnum isfdAnalysisMaterialTypeEnum = forValue(value);
        if (isfdAnalysisMaterialTypeEnum == null) {
            return null;
        }
        return isfdAnalysisMaterialTypeEnum.getDesc();
    }

    public static IsfdAnalysisMaterialTypeEnum forValue(String value) {
        if (StringUtils.isBlank(value)) {
            return null;
        }
        for (IsfdAnalysisMaterialTypeEnum isfdAnalysisClassificationTypeEnum : IsfdAnalysisMaterialTypeEnum.values()) {
            if (isfdAnalysisClassificationTypeEnum.getValue().equals(value)) {
                return isfdAnalysisClassificationTypeEnum;
            }
        }
        return null;
    }

    public static IsfdAnalysisMaterialTypeEnum forDesc(String desc) {
        if (desc == null) {
            return null;
        }
        for (IsfdAnalysisMaterialTypeEnum isfdAnalysisClassificationTypeEnum : IsfdAnalysisMaterialTypeEnum.values()) {
            if (desc.equals(isfdAnalysisClassificationTypeEnum.getDesc())) {
                return isfdAnalysisClassificationTypeEnum;
            }
        }
        return null;
    }
}
